﻿

$(function () {
    setTimeout(function () {
        $("#eventsMenuContent").find(".work-submenu-child").each(function () {
            var len = $(this).find(".work-child-item[data-event-type='1']").length;
            if (len == 0)
                $(this).hide();
            else {
                $(this).find(".work-child-item[data-event-type='2']").hide();
                $(this).find(".work-child-item[data-event-type='3']").hide();
            }
        });
    }, 1500);


    //各种事件类型切换
    $("#event-type-box div").click(function () {
        $(this).addClass("active").siblings().removeClass("active");
        eventType = $(this).attr("data-type");

        $("#eventsMenuContent").find(".work-submenu-child").each(function () {
            var len = $(this).find(".work-child-item[data-event-type='" + eventType + "']").length;
            if (len == 0)
                $(this).hide();
            else {
                $(this).show();
                $(this).find(".work-child-item[data-event-type='" + eventType + "']").show();
                if (eventType == "1") {
                    $(this).find(".work-child-item[data-event-type='2']").hide();
                    $(this).find(".work-child-item[data-event-type='3']").hide();
                } else if (eventType == "2") {
                    $(this).find(".work-child-item[data-event-type='1']").hide();
                    $(this).find(".work-child-item[data-event-type='3']").hide();
                } else {
                    $(this).find(".work-child-item[data-event-type='1']").hide();
                    $(this).find(".work-child-item[data-event-type='2']").hide();
                }
            }
        });


        $("#eventsMenuContent").find(".work-child-item").each(function () {
            var dataId = $(this).attr("data-id");
            mark.showMark(dataId, false);
        });

        $("#eventsMenuContent").find(".check").each(function () {
            if ($(this).hasClass("active")) {
                $(this).parent().next().find(".work-child-item").each(function () {
                    if ($(this).attr("data-event-type") == eventType) {
                        var dataId = $(this).attr("data-id");
                        mark.showMark(dataId, true);
                    }
                });
            } 
        });
    });



    //三级菜单显隐
    $("#eventsMenuContent").on("click", ".check", function () {
        var oCheck = $(this);
        var oParents = oCheck.parents(".work-submenu-content");
        //var allCheckControl = $(this).parent().parent().parent().parent().parent().parent().parent().find(".allCheck");

        if ($(this).hasClass("active")) {
            //隐藏
            oCheck.removeClass("active");

            oCheck.parent().next().addClass("isHide");
            oCheck.parent().next().find(".work-child-item").attr("title", "请先勾选地图显示，再查看具体信息");
            //allCheckControl.removeClass("active");
            oCheck.parent().next().find(".work-child-item").each(function () {
                var dataId = $(this).attr("data-id");
                mark.showMark(dataId, false);
            });
        } else {
            //显示
            oCheck.addClass("active");

            oCheck.parent().next().removeClass("isHide");
            oCheck.parent().next().find(".work-child-item").attr("title", "");
            oCheck.parent().next().find(".work-child-item").each(function () {
                if ($(this).attr("data-event-type") == eventType) {
                    var dataId = $(this).attr("data-id");
                    mark.showMark(dataId, true);
                }
            });
        }

        return false;
    });
});



